package com.ha.auto_skip.adapter;

import android.content.Context;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.viewbinding.ViewBinding;

import com.ha.auto_skip.bean.AppInfoBean;
import com.ha.auto_skip.databinding.AdapterAppInfoBinding;
import com.xinkao.skmvp.adapter.SkRecyclerViewAdapter;
import com.xinkao.skmvp.adapter.SkRecyclerViewHolder;

public class AppInfoAdapter extends SkRecyclerViewAdapter<AppInfoBean> {
    @Override
    protected ViewBinding getLayout(Context context, int viewType) {
        return AdapterAppInfoBinding.inflate(LayoutInflater.from(context));
    }

    @Override
    protected SkRecyclerViewHolder<AppInfoBean> getHolder(@NonNull ViewBinding binding, int viewType) {
        return new Holder(binding);
    }

    static class Holder extends SkRecyclerViewHolder<AppInfoBean> {

        AdapterAppInfoBinding binding;

        public Holder(@NonNull ViewBinding binding) {
            super(binding);

            this.binding = (AdapterAppInfoBinding) binding;
        }

        @Override
        public void setData(@NonNull AppInfoBean bean, int position) {
            binding.name.setText(bean.getLabel());
            binding.appIcon.setImageDrawable(bean.getIcon());
        }
    }
}
